var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
    })(e, t);
}, function(e, t) {
    function n() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
    new n());
}), a = this && this.__decorate || function(e, t, n, o) {
    var s, r = arguments.length, i = r < 3 ? t : null === o ? o = Object.getOwnPropertyDescriptor(t, n) : o;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(e, t, n, o); else for (var a = e.length - 1; 0 <= a; a--) (s = e[a]) && (i = (r < 3 ? s(i) : 3 < r ? s(t, n, i) : s(t, n)) || i);
    return 3 < r && i && Object.defineProperty(t, n, i), i;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("PersonView"), s = e("Global"), c = e("AudioManager"), l = e("GameData"), d = e("EggsManager"), u = e("DataManager"), p = e("LoadManager"), h = e("UIManager"), f = e("WebManager"), g = cc._decorator, m = g.ccclass, y = g.property, v = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.data = [ {
            pos: {
                x: 0,
                y: 0
            },
            size: {
                x: 100,
                y: 100
            },
            personIdx: 103,
            eggIdx: 16
        } ], e.personView = null, e.mask = null, e.particle = null, e.time = 3, e.count = 0, 
        e.total = 9, e.idx = 0, e.items = [], e;
    }
    return i(e, t), e.prototype.onLoad = function() {
        cc.systemEvent.on("refresh_person_skin", this.doRefresh, this), this.node.on("follow_success", this.doReward, this);
    }, e.prototype.onDestroy = function() {
        cc.systemEvent.off("refresh_person_skin", this.doRefresh, this);
    }, e.prototype.onClick = function(e, t) {
        var n, o, s = this, r = t ? JSON.parse(t) : null;
        r && this.personView.personIdx == r.personIdx && -1 == d.default.getInstance().checkEggPerson(r.eggIdx) && (0 == this.count && this.scheduleOnce(this.doTimer, this.time), 
        this.count < this.total ? (f.default.getInstance().sentLog("触发皮肤彩蛋id:" + r.eggIdx), 
        c.default.getInstance().playAudio("按钮2"), this.particle ? ((n = cc.instantiate(this.particle.node)).parent = e.target, 
        (t = n.getComponent(cc.ParticleSystem)).autoRemoveOnFinish = !0, t.resetSystem()) : ((n = new cc.Node()).parent = e.target, 
        o = n.addComponent(cc.ParticleSystem), cc.resources.load("particle/aixin", cc.ParticleAsset, function(e, t) {
            o.file = t, p.default.getInstance().loadRes({
                url: "particle/aixin",
                type: cc.SpriteFrame
            }).then(function(e) {
                o.spriteFrame = e, o.resetSystem();
            });
        }), this.particle = o), this.count++) : (this.idx = r.eggIdx, 16 != this.idx || !GA.isPlatform([ GA.Platform.ByteDance, GA.Platform.Kwaigame ]) || l.GD.isFollow ? this.doReward(this.idx) : h.default.getInstance().loadPnl("eggsTips").then(function(e) {
            e && (e.target = s.node);
        })));
    }, e.prototype.doReward = function(t) {
        var e = this;
        16 == (t = void 0 === t ? this.idx : t) ? c.default.getInstance().playAudio("彩蛋皮肤惨叫鸡") : c.default.getInstance().playAudio("皮肤出现"), 
        f.default.getInstance().sentLog("获得皮肤彩蛋id:" + t), 0 < s.G.eggPersonModelList.filter(function(e) {
            return e.id == t;
        }).length && this.personView.loadEggPerson(t).then(function() {
            e.personView.changeGun(e.personView.gunIdx), h.default.getInstance().loadPopPnl("egg_reward", {
                type: s.RewardType.SKIN,
                idx: t
            }), d.default.getInstance().updateEggPerson(t), l.GD.personIdx = -t - 1, l.GD.eggsHintState = 1, 
            u.default.getInstance().save();
        });
    }, e.prototype.start = function() {
        this.init();
    }, e.prototype.init = function() {
        var s = this;
        this.data.forEach(function(e) {
            var t = new cc.Node();
            t.setPosition(e.pos.x, e.pos.y), t.setContentSize(e.size.x, e.size.y), t.setParent(s.node);
            var n = t.addComponent(cc.Button), o = new cc.Component.EventHandler();
            o.target = s.node, o.component = "EggsPersonView", o.handler = "onClick", o.customEventData = JSON.stringify({
                personIdx: e.personIdx,
                eggIdx: e.eggIdx
            }), n.clickEvents.push(o), s.items.push({
                personIdx: e.personIdx,
                eggIdx: e.eggIdx,
                node: t
            });
        });
    }, e.prototype.doRefresh = function() {
        var t = this;
        this.items.forEach(function(e) {
            return e.node.active = -1 == d.default.getInstance().checkEggPerson(e.eggIdx) && e.personIdx == t.personView.personIdx;
        }), this.count = 0;
    }, e.prototype.doTimer = function() {
        this.count = 0;
    }, e.prototype.stopTimer = function() {
        this.unschedule(this.doTimer);
    }, a([ y(r.default) ], e.prototype, "personView", void 0), a([ y(cc.Node) ], e.prototype, "mask", void 0), 
    a([ m ], e);
}(cc.Component);

n.default = v;